/******FIGURE I: EFFECTS BY DISTANCE FROM POLICE KILLING***********/

/*******RUN ANALYSIS**********/
use ../data/main_distance.dta, clear

reghdfe reg sht_cb sht_pt* , absorb(cb pop_dec#elec_yr) cluster(CBG)
parmest, saving(../estimates/distance_none, replace)
outreg2 using ../output/table_distance.xls, append stats(coef se) ctitle(`y') dec(3) alpha(.01, .05, .10) addtext(model, none) symbol(***, **, *) excel side

reghdfe reg CBGsht_cb CBGsht_pt* , absorb(cb pop_dec#elec_yr CBG#elec_yr) cluster(CBG)
parmest, saving(../estimates/distance_cbg, replace)
outreg2 using ../output/table_distance.xls, append stats(coef se) ctitle(`y') dec(3) alpha(.01, .05, .10) addtext(model, CBG) symbol(***, **, *) excel side

/*******CREATE FIGURES*********/
local color1 = "navy"
local color2 = "maroon*0.65"
local symbol1 = "circle"
local symbol2 = "diamond"

local lwidth = "medthick"
local msize = "medlarge"
local tsize = "medlarge"
local labsize = "medium"
local titlesize = "vlarge"

use "../estimates/distance_none", clear
gen cbg =0
append using "../estimates/distance_cbg"
replace cbg = 1 if cbg==.

gen dist = real(substr(parm, -3, 3))
replace dist = real(substr(parm, -2, 2)) if dist==.
replace dist = 0 if dist==.

replace dist = 80 if parm=="_cons"
replace estimate = 0 if parm=="_cons"
replace min95 = 0 if parm=="_cons"
replace max95 = 0 if parm=="_cons"

replace dist = 210 if strpos(parm, "ov200")!=0

gen dist1 = dist
replace dist1 = dist+1.5 if cbg==1
replace dist1 = dist-1.5 if cbg==0

#delimit ;
graph twoway (scatter est dist1 if cbg==0,  msymbol(`symbol1') mcolor(`color1') ) (rcap min95 max95 dist1 if cbg==0, msize(vtiny) lcolor(`color1')) 
(scatter est dist1 if cbg==1,   msymbol(`symbol2') mcolor(`color2')) (rcap min95 max95 dist1 if cbg==1, msize(vtiny) lcolor(`color2')), 
xlabel(0 "In CB" 10 "0.1" 20 "0.2" 30 "0.3" 40 "0.4" 50 "0.5" 60 "0.6" 70 "0.7" 80 "0.8" 90 "0.9" 100 "1.0"
110 "1.1" 120 "1.2" 130 "1.3" 140 "1.4" 150 "1.5" 160 "1.6" 170 "1.7" 180 "1.8" 190 "1.9" 200 "2.0" 210 ">2.0", labsize(`labsize')) xsize(16) ysize(7)
ytitle("Registrations", size(`tsize'))
yline(0, lcolor(red))
ylabel(-5(5)10) yscale(range(-5 10))
xtitle("Distance from police killing (miles)", size(`tsize'))
legend(order(1 3) label(1 "Election FEs") label(3 "Block Group-Election FEs") size(`tsize')) ///
plotregion(fcolor(white)) graphregion(fcolor(white) lcolor(white)) bgcolor(white);
graph export ../output/fig1_distance.png, replace width(12000);
graph export ../output/fig1_distance.eps, replace ;

#delimit cr
